package com.example.meeting.mapper;

import com.example.meeting.model.domain.Person;
import org.apache.ibatis.annotations.*;
import java.util.List;

@Mapper
public interface PersonMapper {

    //根据admin扩展到person
    @Insert("INSERT INTO person(id, name) VALUES(#{id},#{name})")
    //@Options(useGeneratedKeys = true,keyProperty = "id",keyColumn = "id")
    void addPersonByAdmin(Integer id, String name);

    @Select("SELECT * FROM person WHERE name=#{name}")
    Person selectPersonByName(String name);

    List<Person> selectPersonList(Person person);

    List<Person> selectPersonListByIds(@Param("ids") List<Long> ids);

    // person表维护列席人员信息
    @Insert("INSERT INTO person(name,phone) VALUES(#{name},#{phone})")
    @Options(useGeneratedKeys = true,keyProperty = "id",keyColumn = "id")
    Integer addPerson(Person person);

    Integer updatePerson(Person person);

    //根据议题id查询对应成员信息
    @Select("SELECT * FROM person WHERE id IN(SELECT p_id FROM subject_person WHERE s_id=#{sId})")
    List<Person> selectPersonBySId(Long sId);
}
